<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Raxan for PHP Overview | Raxan User Guide</title>
    <link href="../raxan/styles/master.css" rel="stylesheet" type="text/css" />
    <!--[if IE]><link rel="stylesheet" href="../raxan/styles/master.ie.css" type="text/css"><![endif]-->
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="highlight/styles/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="highlight/highlight.js"></script>
    <script type="text/javascript">
        hljs.initHighlightingOnLoad('javascript','html','php');
    </script>

</head>

<body>
    <div class="container c48 prepend-top">
        <h2 class="bottom">Raxan User Guide</h2>
        <div class="navbar">
            <div class="lf"><div class="rt"><div class="md">
                <ul>
                    <li><a href="../index.html" title="The Rich Ajax, CSS &amp; PHP Framework" >Home</a></li>
                    <li><a href="table-of-contents.html" title="Blog Posts" >Table Of Contents</a></li>
                    <li><a href="../php-examples/index.php" title="PHP Examples" >PHP Examples</a></li>
                    <li><a href="../css-examples/index.html" title="User Guide" >CSS Examples</a></li>
                </ul>
            </div></div></div>
        </div>
        <div class="prepend1 append1">
            <div class="ltm" align="right">
                <a href="table-of-contents.html" title="Show Table of Content">
                    <img src="images/toc-button.png"  alt="Table of Contents" />
                </a>
            </div>
            <h2>Raxan for PHP Overview</h2>

<div align="center" class="pad">
    <img class="margin" src="images/pdi-architect.gif" />
</div>

<p>Raxan for PHP is an event driven PHP/Ajax framework that is based on a Programmable Document Interface (PDI) design. The framework was designed to meet the needs of modern web application development while allowing clean separation of web application layers, easy re-use of business logic and parallel development by separate teams.</p>

<p>It is important to note that the core of the framework was inspired by the jQuery JavaScript library. In fact, most of the client/server communications are handled by jQuery. This means that if you're already familiar with basic methodology of jQuery, then you can easily adapt to the methodology and concepts of this framework.</p>

<h3>Web Design Philosophy</h3>

<div class="c9 right pad border margin">
    <img src="images/pdi-folders.png" /><br />
    <span class="small">A typical folder structure of a Raxan application</span>
</div>

<p>Building on the web design philosophy of the separation of content from logic, Raxan makes it very easy for you to separate your html views (or content) from page logic by storing all your html views inside a separate file folder.</p>

<p>Use the views folder to store your HTML, CSS, images and JavaScript files. Once you have created and separated your html files you can from within your page logic, load and process your views using the provided APIs.</p>

<h3>The Web Page Controller</h3>

<p>A typical web page normally includes a reference to the PDI gateway (or auto-start) file and a sub-class of the RaxanWebPage class. The gateway file (raxan/pdi/gateway.php or raxan/pdi/autostart.php) is used to load the main classes that are used by the framework. These classes include Raxan, RaxanWebPage, RaxanElement, RaxanPlugin and RaxanDataSanitizer, etc. The RaxanWebPage class is responsible for collecting, processing and responding to a client's page request.</p>

<p>To automatically initialize a page you can do the following:</p>

<pre><code>&lt;?php
    include_once('raxan/pdi/autostart.php'); // include the auto start file

    class NewPage extends RaxanWebPage {  // extend the RaxanWebPage class
        protected function _load() {
            $this-&gt;content('Hello World'); // set the content of the page
        }    
    }

?&gt;
</code></pre>

<p>If there are more than one classes that extends RaxanWebPage within the same page, the framework will load the last defined class. To prevent this behavior you need to declare the $autostart property within your page startup class:</p>

<pre><code>&lt;?php
    include_once('raxan/pdi/autostart.php'); // include the auto start file

    class AnotherPage extends RaxanWebPage {  // extend the RaxanWebPage class
        protected $autostart;   // tells Raxan to initialize this class when the page loads 
        protected function _load() {
            $this-&gt;content('Hello World'); // set the content of the page
        }    
    }

?&gt;
</code></pre>

<p>Another way to automatically initialize a page class is to set the "autostart" config option:</p>

<pre><code>&lt;?php
    Raxan::config('autostart','MyDefaultPageClass');
?&gt;    
</code></pre>

<p>To manually initialize a page you can do the following:</p>

<pre><code>&lt;?php
    include_once('raxan/pdi/gateway.php'); // include the gateway file

    class NewPage extends RaxanWebPage {  // extend the RaxanWebPage class
        protected function _load() {
            $this-&gt;content('Hello World'); // set the content of the page
        }    
    }

    RaxanWebPage::init('NewPage'); // manually initialize the class

?&gt;
</code></pre>

<p>Note: When the NewPage sub-class is initialized it will serve as the main Page Controller for the web page. To access the page controller from an external class or function, use the RaxanWebPage::Controller() method.</p>

<h3>Chainable API</h3>

<p>Chainable server-side DOM Traversing and Manipulation functions make it very easy to search and modify your html views using simple CSS-selectors. Change HTML tag attributes with a single line of code:</p>

<pre><code>    &lt;?php
        $page['img#Photo']-&gt;attr('alt', 'The World')-&gt;css('width',250);
    ?&gt;
</code></pre>

<h3>Extending the RaxanWebPage class</h3>

<p>In order to receive special event notifications when your page is being processed, you will have to extend the RaxanWebPage class and create custom web Page Controller.</p>

<p>For example, the code below uses the _load() event to modify the content of the web page:</p>

<pre><code>&lt;?php        

class MyPage extends RaxanWebPage {
    protected function _load() {
        $this['body']-&gt;append('Hello World');
    }
}


?&gt;
</code></pre>

<h3>More Information &amp; Examples</h3>

<p>See <a href="table-of-contents.html">General Topics</a> for more information and examples on how to use the Raxan Framework.</p>

<hr />

<p><a href="page-cycle.html">The Page Request Cycle >></a></p>

        </div>
        <div class="tpb pad" style="text-align:right">
            <div class="right ltm">
                <a href="table-of-contents.html" title="Back to Table of Content">
                    <img src="images/toc-button.png"  alt="Table of Contents" />
                </a>
            </div>
        </div>
    </div>
</body>

</html>

